home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / xinu.arc / XINU.H < prev    next >
Text File  |  1986-01-03  |  26KB  |  656 lines

  1. /* bufpool.h  p. 234 */
  2.  
  3. # ifndef    NBPOOLS
  4. # define    NBPOOLS        5    /* maximum number of pools           */
  5. # endif
  6. # ifndef    BPMAXB
  7. # define    BPMAXB        512    /* maximum buffer length             */
  8. # endif
  9. # define    BPMINB        2    /* minimum buffer length             */
  10. # ifndef    BPMAXN
  11. # define    BPMAXN        100    /* maximum buffers in any pool       */
  12. # endif
  13. struct    bpool  {            /* description of a single pool      */
  14.     int    bpsize;            /* size of buffers in this pool      */
  15.     char    *bpnext;        /* pointer to next free buffer       */
  16.     int    bpsem;            /* semaphore that counts buffers     */
  17.     };                /*    currently in THIS pool         */
  18.  
  19. extern struct bpool    bptab[];    /* buffer pool table                 */
  20. extern int    nbpools;        /* current number of pools           */
  21. # ifdef    MEMMARK
  22. extern MARKER    bpmark;
  23. # endif
  24. /* conf.h  p. 142 */
  25.  
  26. # define    NULLPTR        (char *)0
  27.  
  28. /* device table declarations */
  29. struct    devsw  {            /* device table entry                */
  30.     int    dvnum;
  31.     int    (*dvinit)();
  32.     int    (*dvopen)();
  33.     int    (*dvclose)();
  34.     int    (*dvread)();
  35.     int    (*dvwrite)();
  36.     int    (*dvseek)();
  37.     int    (*dvgetc)();
  38.     int    (*dvputc)();
  39.     int    (*dvcntl)();
  40.     int    dvcsr;
  41.     int    dvivec;
  42.     int    dvovec;
  43.     int    (*dviint)();
  44.     int    (*dvoint)();
  45.     char    *dvioblk;
  46.     int    dvminor;
  47.     };
  48.  
  49. extern struct devsw    devtab[];    /* one entry per device              */
  50.  
  51. /* device name definitions */
  52.  
  53. # define    CONSOLE        0    /* type tty */
  54. # define    OTHER        1    /* type tty */
  55. # define    DISK0        2    /* type dsk */
  56. # define    FILE1        3    /* type df  */
  57. # define    FILE2        4    /* type df  */
  58. # define    FILE3        5    /* type df  */
  59. # define    FILE4        6    /* type df  */
  60. # define        MEM             7       /* type mem */
  61.  
  62.  
  63. /* Control block sizes */
  64.  
  65. # define    Ntty        2
  66. # define    Ndsk        1
  67. # define    Ndf        4
  68. # define        Nmem            1
  69. è# define    NDEVS        8
  70.  
  71. /* declarations of I/O routines referrenced */
  72.  
  73. extern int    ttyinit();
  74. extern int    ionull();
  75. extern int    ttyread();
  76. extern int    ttywrite();
  77. extern int    ioerr();
  78. extern int    ttycntl();
  79. extern int    ttygetc();
  80. extern int    ttyputc();
  81. extern int    ttyiin();
  82. extern int    ttyoin();
  83. extern int    dsinit();
  84. extern int    dsopen();
  85. extern int    dsread();
  86. extern int    dswrite();
  87. extern int    dsseek();
  88. extern int    dscntl();
  89. extern int    dsinter();
  90. extern int    lfinit();
  91. extern int    lfclose();
  92. extern int    lfread();
  93. extern int    lfwrite();
  94. extern int    lfseek();
  95. extern int    lfgetc();
  96. extern int    lfputc();
  97. extern int      memread();
  98. extern int      memwrite();
  99.  
  100. /* Configuration and Size Constants */
  101.  
  102. # define    MEMMARK            /* define if memory marking used     */
  103. # define    NPROC        10    /* number of user processes          */
  104. # define    NSEM        50    /* total number of semaphores        */
  105. # define    RTCLOCK            /* system has a real-time clock      */
  106. # define    VERSION        "X.XX (11/9/84)"
  107.                     /* message printed at startup        */
  108. /* dir.h  p. 318 */
  109.  
  110. # define    FDNLEN        10    /* length of file name + 1           */
  111. # define    NFDES        28    /* number of files per directory     */
  112.  
  113. struct    fdes  {                /* description of each file          */
  114.     long    fdlen;            /* length in bytes                   */
  115.     IBADDR    fdiba;            /* first index block                 */
  116.     char    fdname[FDNLEN];        /* null-terminated file name         */
  117. };
  118.  
  119. struct    dir  {                /* directory layout                  */
  120.     int    d_iblks;        /* i-blocks on this disk             */
  121.     DBADDR    d_fblst;        /* pointer to list of free blocks    */
  122.     IBADDR    d_filst;        /* pointer to list of free i-blocks  */
  123.     int    d_id;            /* disk identification integer       */
  124.     int    d_nfiles;        /* current number of files           */
  125.     struct fdes    d_files[NFDES];    /* descriptions of the files         */
  126. };
  127.  
  128. struct    freeblk  {            /* shape of block on free list       */
  129.     DBADDR    fbnext;            /* address of next free block        */
  130. };
  131. /* disk.h - dssync, dsdirec  p. 285 */
  132.  
  133. # include    <xebec.h>        /* disk controller constants         */
  134. # include    <dtc.h>            /* disk interface constants          */
  135.  
  136. typedef    unsigned int    DBADDR;        /* disk data block addresses         */
  137. # define    DBNULL    (DBADDR)0177777    /* null disk block address           */
  138.  
  139. struct    dsblk  {            /* disk driver control block         */
  140.     struct dtc    *dcsr;        /* disk interface csr address        */
  141.     struct dreq    *dreqlst;    /* list of pending requests          */
  142.     int    dnum;            /* device number of this disk        */
  143.     int    dibsem;            /* i-block mutual exclusion semaphore*/
  144.     int    dflsem;            /* free list mutual exclusion semaph */
  145.     int    ddirsem;        /* directory mutual exclusion semaph */
  146.     int    dnfiles;        /* number of currently open files    */
  147.     char    *ddir;            /* address of in-core directory      */
  148.     struct xbdcb    ddcb;        /* hold commands that interface sends*/
  149. };                    /*     to disk controller            */
  150. extern struct dsblk    dstab[];
  151.  
  152. struct    dreq  {                /* node in list of requests          */
  153.     DBADDR    drdba;            /* disk block address to use         */
  154.     int    drpid;            /* process id making request         */
  155.     char    *drbuff;        /* buffer address for read / write   */
  156.     char    drop;            /* operation: READ / WRITE / SEEK    */
  157.     int    drstat;            /* returned status OK / SYSERR       */
  158.     struct dreq    *drnext;    /* ptr to next node on request list  */
  159. };
  160.  
  161. # define    DRNULL    (struct dreq *)0     /* null pointer in request list */
  162. # define    DIRBLK        0    /* block used to hold directory      */
  163. # define    DONQ        2    /* status if request enqueued        */
  164. # define    DBUFSIZ        512    /* size of disk data block           */
  165. # define    DREQSIZ    sizeof(struct dreq)  /* size of disk request node    */
  166. # ifndef    NDBUFF
  167. # define    NDBUFF        10    /* number fo disk data buffers       */
  168. # endif
  169. # define    NDREQ        10    /* number of disk request buffers    */
  170. # define    DREAD        XOREAD    /* read command in dreq.drop         */
  171. # define    DWRITE        XOWRITE    /* write command in dreq.drop        */
  172. # define    DSEEK        XOSEEK    /* seek command in dreq.drop         */
  173. # define    DSYNC        XOTDR    /* sync command in dreq.drop         */
  174.  
  175. extern int    dskrbp;            /* disk request node buffer pool     */
  176. extern int    dskdbp;            /* disk data block buffer pool       */
  177.  
  178. /* disk control function codes */
  179.  
  180. # define    DSKSYNC        0    /* synchronize ( flush all I/O )     */
  181.  
  182. # define    dssync(ddev)    control((ddev),DSKSYNC);
  183. # define    dsdirec(ddev)    ((struct dir *)devtab[ddev].dvioblk->ddir)
  184. /* dtc.h  p. 284 */
  185.  
  186. /* Digital Technology Corp. DTC-11-1 disk controller host interface */
  187.  
  188. struct    dtc  {                /* controller interface registers    */
  189.     int    dt_ccsr;        /* command completion status         */
  190.     int    dt_csr;            /* control and status register       */
  191.     char    *dt_dar;        /* data address register             */
  192.     struct xbdcb    *dt_car;    /* command address register          */
  193.     int    dt_xdar;        /* extension of dar (not used)       */
  194.     int    dt_xcar;        /* extension of car (not used)       */
  195. };
  196.  
  197. /* bits in the dtc csr register */
  198.  
  199. # define    DTGO        0000001    /* "go" bit - start interface        */
  200. # define    DTRESET        0000002    /* "force reset" bit                 */
  201. # define    DTINTR        0000100    /* enable interface interrupt        */
  202. # define    DTDONE        0000200    /* command done                      */
  203. # define    DTERROR        0100000    /* some error occurred               */
  204. /* file.h  p. 320 */
  205.  
  206. /*  Local disk layout: disk block 0 is directory, then index area, and then  *
  207.  *  data blocks.  Each disk block (512 bytes) in the index area contains 8   *
  208.  *  i-blocks, which are 64 bytes long.  Iblocks are referenced relative to 0 *
  209.  *  so the disk block address of iblock k is given by truncate(k/8)+1.  The  *
  210.  *  offset of iblock k within its disk block is given by 64*remainder(k,8).  *
  211.  *  The directory entry points to a linked list of iblocks, and each iblock  *
  212.  *  contains pointers to IBLEN (29) data blocks.  Index pointers contain a   *
  213.  *  valid data block address of DBNULL.                                      */
  214.  
  215. # include    <iblock.h>
  216.  
  217. # define    EOF        -2    /* value returned on end-of-file     */
  218. # define    FLREAD        001    /* fl_mode bit for "read"            */
  219. # define    FLWRITE        002    /* fl_mode bit for "write"           */
  220. # define    FLRW        003    /* fl_mode bits for read+write       */
  221. # define    FLNEW        010    /* fl_mode bit for "new file"        */
  222. # define    FLOLD        020    /* fl_mode bit for "old file"        */
  223.  
  224. struct    flblk  {            /* file "device" control block       */
  225.     int    fl_id;            /* file's "device id" in devtab      */
  226.     int    fl_dev;            /* file is on this disk device       */
  227.     int    fl_pid;            /* process id accessing the file     */
  228.     struct fdes    *fl_dent;    /* file's in-core directory entry    */
  229.     int    fl_mode;        /* read, write, or both              */
  230.     IBADDR    fl_iba;            /* address of iblock in fl_iblk      */
  231.     struct iblk    fl_iblk;    /* current iblock for file           */
  232.     int    fl_ipnum;        /* current iptr in fl_iblk           */
  233.     long    fl_pos;            /* current file position (bytes)     */
  234.     Bool    fl_dch;            /* has fl_buff been changed ?        */
  235.     char    *fl_bptr;        /* ptr to next character in fl_buff  */
  236.     char    fl_buff[DBUFSIZ];    /* current data block for file       */
  237. };
  238.  
  239. # ifdef    Ndf
  240. extern struct flblk    fltab[];
  241. # endif
  242. /* iblock.h - ibtodb, ibdisp  p. 310 */
  243.  
  244. typedef int    IBADDR;            /* iblocks addressed 0, 1, 2, ...    */
  245.  
  246. # define    IBLEN        29    /* # d-block pointers in an i-block  */
  247. # define    IBNULL        -1    /* null pointer in i-block list      */
  248. # define    IBAREA        1    /* start if iblocks on disk          */
  249. # define    IBWDIR        TRUE    /* ibnew: write directory            */
  250. # define    IBNWDIR        FALSE    /* ibnew: don't write directory      */
  251.  
  252. struct    iblk  {                /* index block layout                */
  253.     long    ib_byte;        /* 1st d-byte indexed by this iblock */
  254.     IBADDR    ib_next;        /* address of next i-block           */
  255.     DBADDR    ib_dba[IBLEN];        /* pointers to data blocks indexed   */
  256. };
  257.  
  258. # define    ibtodb(ib)    (((ib)>>3)+IBAREA)/*iblock to disk block addr*/
  259. # define    ibdisp(ib)    (((ib)&07)*sizeof(struct iblk))
  260. /* io.h - fgetc, fputc, getchar, isbaddev, putchar  p. 116 */
  261.  
  262. #define    INTVECI        inint    /* input interrupt dispatch routine  */
  263. #define    INTVECO        outint    /* output interrupt dispatch routine */
  264.  
  265. extern int    INTVECI();
  266. extern int    INTVECO();
  267.  
  268. struct    intmap  {        /* device-to-interrupt routine mapping       */
  269.     int    (*iin)();    /* address of input interrupt routine        */
  270.     int    icode;        /* argument passed to input routine          */
  271.     int    (*iout)();    /* address of output interrupt routine       */
  272.     int    ocode;        /* argument passed to output routine         */
  273. };
  274.  
  275. #ifdef    NDEVS
  276. extern struct intmap    intmap[NDEVS];
  277. #define    isbaddev(f)    ((f)<0 || (f)>=NDEVS)
  278. #endif
  279.  
  280. /* In-line I/O procedures */
  281.  
  282. #define    getchar()    getc(CONSOLE)
  283. #define    putchar(ch)    putc(CONSOLE,(ch))
  284. #define    fgetc(unit)    getc((unit))
  285. #define    fputc(unit,ch)    putc((unit),(ch))
  286.  
  287.  
  288. struct    vector  {
  289.     char    *vproc;        /* address of interrupt procedure */
  290.     int    vps;        /* saved process status word */
  291. };
  292. /* kernel.h - disable, enable, halt, restore, isodd  p. 72 */
  293.  
  294. /* Symbolic constants used throughout Xinu */
  295.  
  296. #define    Bool    char        /* Boolean type                      */
  297. #define    FALSE    0         /* Boolean constants                 */
  298. #define    TRUE    1
  299. #define    NULL    (char *)0    /* Null pointer for linked lists     */
  300. #define    SYSCALL    int        /* System call declaration           */
  301. #define    LOCAL    static        /* Local procedure declarations      */
  302. #define    INTPROC    int        /* Interrupt procedure declaration   */
  303. #define    PROCESS int        /* Process declaration               */
  304. #define    RESCHYES    1    /* tell ready to reschedule          */
  305. #define    RESCHNO        0    /* tell ready not to reschedule      */
  306. #define    MININT    0100000        /* minimum integer (-32768)          */
  307. #define    MAXINT    0077777        /* maximum integer (32767)           */
  308. #define    SP    6        /* register 6 is stack pointer       */
  309. #define    PC    7        /* register 7 is program counter     */
  310. #define    PS    8        /* register 8 is processor status    */
  311. #define    MINSTK    40        /* minimum process stack size        */
  312. #define    NULLSTK    300        /* process 0 stack size              */
  313. #define    DISABLE    0340        /* PS to disable interrupts          */
  314. #define    OK    1        /* returned when system call ok      */
  315. #define    SYSERR    -1        /* returned when system call fails   */
  316.  
  317. /* initialization constants */
  318.  
  319. #define    INITARGC    1    /* initial process argc              */
  320. #define    INITSTK        200    /* initial process stack             */
  321. #define    INITPRIO    20    /* initial process priority          */
  322. #define    INITNAME    "main"    /* initial process name              */
  323. #define    INITRET        userret    /* processes return address          */
  324. #define    INITPS        0    /* initial process PS                */
  325. #define    INITREG        0    /* initial register contents         */
  326. #define    QUANTUM        10    /* clocks ticks until preemption     */
  327.  
  328. /* misc. utility inline functions */
  329.  
  330. #define    isodd(x)    (01&(int)(x))
  331. #define    disable(ps)    asm("mfps ~ps");asm("mtps $0340")
  332. #define    restore(ps)    asm("mtps ~ps")    /* restore interrupt status  */
  333. #define    enable()    asm("mtps $000")/* enable interrupts */
  334. #define    pause()        asm("wait")    /* machine "wait for interr."*/
  335. #define    halt()        asm("halt")    /* machine halt instruction  */
  336.  
  337. extern int    rdyhead, rdytail;
  338. extern int    preempt;
  339. /* mark.h - unmarked  p. 232 */
  340.  
  341. # ifndef    MAXMARK
  342. # define    MAXMARK        20    /* maximum number of marked locations*/
  343. # endif
  344. # ifdef    MEMMARK
  345. extern int    *(marks[]);
  346. extern int    nmarks;
  347. extern int    mkmutex;
  348. typedef int    MARKER[1];        /* by declaring it to be an array,   */
  349.                     /* the name provides an address so   */
  350.                     /* forgotten &'s don't become a prob.*/
  351.  
  352. # define    unmarked(L)    (L[0]<0 || L[0]>=nmarks || marks[L[0]]!=L)
  353. # endif
  354. /* mem.h - freestk, roundew, truncew  p. 105 */
  355.  
  356. /*-----------------------------------------------------------------------------
  357.  * roundew, truncew - round or truncate address to next even word
  358.  *-----------------------------------------------------------------------------
  359.  */
  360. # define    roundew(x)    (int *)((3 + (int)(x)) & (~3))
  361. # define    truncew(x)    (int *)(((int)(x)) & (~3))
  362.  
  363. /*-----------------------------------------------------------------------------
  364.  *  freestk  --  free stack memory allocated by getstk
  365.  *-----------------------------------------------------------------------------
  366.  */
  367. # define    freestk(p,len)    freemem((unsigned)(p)               \
  368.                     - (unsigned)(roundew(len))  \
  369.                     + (unsigned)sizeof(int),    \
  370.                     roundew(len))
  371.  
  372. struct    mblock  {
  373.     struct mblock    *mnext;
  374.     unsigned int    mlen;
  375.     };
  376. extern struct mblock    memlist;    /* head of free memory list          */
  377. extern int    *maxaddr;        /* max memory address                */
  378. extern int    end;            /* address beyond loaded memory      */
  379. /* ports.h - isbadport  p. 242 */
  380.  
  381. # define    NPORTS        30    /* maximum number of ports           */
  382. # define    MAXMSGS        100    /* maximum messages on all ports     */
  383. # define    PTFREE        '\01'    /* port is free                      */
  384. # define    PTLIMBO        '\02'    /* port is being deleted/reset       */
  385. # define    PTALLOC        '\03'    /* port is allocated                 */
  386. # define    PTEMPTY        -1    /* initial semaphore entries         */
  387.  
  388. struct    ptnode  {            /* node on list of message pointers  */
  389.     int    ptmsg;            /* a one-word message                */
  390.     int    *ptnext;        /* address of next node on list      */
  391. };
  392.  
  393. struct    pt  {                /* entry in the port table           */
  394.     char    ptstate;        /* port state FREE/LIMBO/ALLOCATED   */
  395.     int    ptssem;            /* sender semaphore                  */
  396.     int    ptrsem;            /* receiver semaphore                */
  397.     int    ptmaxcnt;        /* max messages to be queued         */
  398.     int    ptseq;            /* sequence changed at creation      */
  399.     struct ptnode    *pthead;    /* list of message pointers          */
  400.     struct ptnode    *pttail;    /* tail of message list              */
  401. };
  402.  
  403. extern struct ptnode    *ptfree;    /* list of free nodes                */
  404. extern struct pt    ports[];    /* port table                        */
  405. extern int    ptnextp;        /* next port to examine when looking */
  406.                     /*     for a free one                */
  407. # ifdef    MEMMARK
  408. extern MARKER    ptmark;
  409. # endif
  410.  
  411. # define    isbadport(pid)        ((pid)<0 || (pid)>=NPORTS)
  412. /* proc.h - isbadpid  p. 54 */
  413.  
  414. /* process table declarations and defined constants                          */
  415.  
  416. # ifndef    NPROC
  417. # define    NPROC        10    /* set the number of processes       */
  418. # endif                    /* allowed if not already done       */
  419.  
  420. /* process state constants */
  421.  
  422. # define    PRCURR        '\01'    /* process is currently running      */
  423. # define    PRFREE        '\02'    /* process slot is free              */
  424. # define    PRREADY        '\03'    /* process is on ready queue         */
  425. # define    PRRECV        '\04'    /* process waiting for message       */
  426. # define    PRSLEEP        '\05'    /* process is sleeping               */
  427. # define    PRSUSP        '\06'    /* process is suspended              */
  428. # define    PRWAIT        '\07'    /* process is on semaphore queue     */
  429.  
  430. /* miscellaneous process definitions */
  431.  
  432. # define    PNREGS        9    /* size of saved register area       */
  433. # define    PNMLEN        8    /* length of process "name"          */
  434. # define    NULLPROC    0    /* id of the null process; it is     */
  435.                     /* always eligible to run            */
  436.  
  437. # define    isbadpid(x)    (x<=0 || x>=NPROC)
  438.  
  439. /* process table entry */
  440.  
  441. struct    pentry  {
  442.     char    pstate;            /* process state: PRCURR, etc.       */
  443.     short    pprio;            /* process priority                  */
  444.     short    pregs[PNREGS];        /* saved regs. R0-R5, SP, PC, PS     */
  445.     short    psem;            /* semaphore if process waiting      */
  446.     short    pmsg;            /* message sent to this process      */
  447.     short    phasmsg;        /* nonzero iff pmsg is valid         */
  448.     short    pbase;            /* base of run time stack            */
  449.     short    pstklen;        /* stack length                      */
  450.     short    plimit;            /* lowest extent of stack            */
  451.     char    pname[PNMLEN];        /* process name                      */
  452.     short    pargs;            /* initial number of arguments       */
  453.     short    paddr;            /* initial code address              */
  454. };
  455.  
  456. extern struct pentry    proctab[];
  457. extern int    numproc;        /* currently active processes        */
  458. extern int    nextproc;        /* search point for free slot        */
  459. extern int    currpid;        /* currently executing process       */
  460. /* q.h - firstid, firstkey, isempty, lastkey, nonempty  p. 44 */
  461.  
  462. /* q structure declarations, constants, and inline procedures                */
  463.  
  464. # ifndef    NQENT
  465. # define    NQENT        NPROC + NSEM + NSEM + 4    /* for ready & sleep */
  466. # endif
  467.  
  468. struct    qent  {            /* one for each process plus two for         */
  469.                 /* each list                                 */
  470.     short    qkey;        /* key on which the queue is ordered         */
  471.     short    qnext;        /* pointer to next process or tail           */
  472.     short    qprev;        /* pointer to previous process or head       */
  473.     };
  474.  
  475. extern struct qent    q[];
  476. extern int    nextqueue;
  477.  
  478. /* inline list manipulation procedures */
  479.  
  480. # define    isempty(list)    (q[(list)].qnext >= NPROC)
  481. # define    nonempty(list)    (q[(list)].qnext < NPROC)
  482. # define    firstkey(list)    (q[q[(list)].qnext].qkey)
  483. # define    lastkey(tail)    (q[q[(tail)].qprev].qkey)
  484. # define    firstid(list)    (q[(list)].qnext)
  485.  
  486. # define    EMPTY    -1    /* equivalent of null pointer                */
  487. /* sem.h - isbadsem  p. 84 */
  488.  
  489. # ifndef    NSEM
  490. # define    NSEM    45    /* number of semaphores, if not defined      */
  491. # endif
  492.  
  493. # define    SFREE    '\01'        /* this semaphore is free            */
  494. # define    SUSED    '\02'        /* this semaphore is used            */
  495.  
  496. struct    sentry  {            /* semaphore table entry             */
  497.     char    sstate;            /* the state SFREE or SUSED          */
  498.     short    semcnt;            /* count for this semaphore          */
  499.     short    sqhead;            /* q index of head of list           */
  500.     short    sqtail;            /* q index of tail of list           */
  501. };
  502. extern struct sentry    semaph[];
  503. extern int    nextsem;
  504.  
  505. # define    isbadsem(s)    (s<0 || s>=NSEM)
  506. /* sleep.h  p. 130 */
  507.  
  508.  
  509. # define    CVECTOR    0100    /* location of clock interrupt vector        */
  510.  
  511. extern int    clkruns;    /* 1 iff clock exists; 0 otherwise           */
  512.                 /* Set at system startup.                    */
  513. extern int    clockq;        /* q index of sleepin process list           */
  514. extern int    count6;        /* used to ignore 5 of 6 interrupts          */
  515. extern int    *sltop;        /* address of first key on clockq            */
  516. extern int    slnempty;    /* 1 iff clockq is nonempty                  */
  517.  
  518. extern int    defclk;        /* >0 iff clock interrupts are deferred      */
  519. extern int    clkdiff;    /* number of clock clicks deferred           */
  520. extern int    clkint();    /* clock interrupt handler                   */
  521. /* slu.h  p. 168 */
  522.  
  523.  
  524. /* standart serial line unit device constants */
  525.  
  526. # define    SLUENABLE    0100    /* device interrupt enable bit       */
  527. # define    SLUREADY    0200    /* device ready bit                  */
  528. # define    SLUDISABLE    0000    /* device interrupt disable mask     */
  529. # define    SLUTBREAK    0001    /* transmitter break-mode bit        */
  530. # define    SLUERMASK    0170000    /* mask for error flags on input     */
  531. # define    SLUCHMASK    0377    /* mask for input character          */
  532.  
  533. /* SLU device register layout and correspondence to vendor's names */
  534.  
  535. struct    csr  {
  536.     int    crstat;        /* receiver control and status        (RCSR) */
  537.     int    crbuf;        /* receiver data buffer               (RBUF) */
  538.     int    ctstat;        /* transmitter control and status     (XCSR) */
  539.     int    ctbuf;        /* transmitter data buffer            (XBUF) */
  540.     };
  541. /* tty.h  p. 161 */
  542.  
  543. # define    IOCHERR        0200    /* bit set on when an error          */
  544.                     /* occurred readint the character    */
  545. # define    OBMINSP        20    /* minimum space in buffer before    */
  546.                     /* processes awakened to write       */
  547. # define    EBUFLEN        20    /* size of echo queue                */
  548.  
  549. /* size constants */
  550.  
  551. # ifndef    Ntty
  552. # define    Ntty        1    /* number of serial tty lines        */
  553. # endif
  554. # ifndef    IBUFLEN
  555. # define    IBUFLEN        128    /* number of chars in input queue    */
  556. # endif
  557. # ifndef    OBUFLEN
  558. # define    OBUFLEN        64    /* number of chars in output queue   */
  559. # endif
  560.  
  561. /* mode constants */
  562.  
  563. # define    IMRAW        'R'    /* raw mode => nothing done          */
  564. # define    IMCOOKED    'C'    /* cooked mode => line editing       */
  565. # define    IMCBREAK    'K'    /* honor echo, etc., no line editing */
  566. # define    OMRAW        'R'    /* raw mode => normal processing     */
  567.  
  568. struct    tty  {                /* tty line control block            */
  569.     int    ihead;            /* head of input queue               */
  570.     int    itail;            /* tail of input queue               */
  571.     char    ibuff[IBUFLEN];        /* input bruffer for this line       */
  572.     int    isem;            /* input semaphore                   */
  573.     int    ohead;            /* head of output queue              */
  574.     int    otail;            /* tail of output queue              */
  575.     char    obuff[OBUFLEN];        /* output bruffer for this line      */
  576.     int    osem;            /* output semaphore                  */
  577.     int    odsend;            /* sends delayed for space           */
  578.     int    ehead;            /* head of echo queue                */
  579.     int    etail;            /* tail of echo queue                */
  580.     char    ebuff[EBUFLEN];        /* echo queue                        */
  581.     char    imode;            /* IMRAW, IMCBREAK, IMCOOKED         */
  582.     Bool    iecho;            /* is input echoed?                  */
  583.     Bool    ieback;            /* do erasing backspace on echo?     */
  584.     Bool    evis;            /* echo control characters as ^X ?   */
  585.     Bool    ecrlf;            /* echo CR-LF for newline?           */
  586.     Bool    icrlf;            /* map '\r' to '\n' on input?        */
  587.     Bool    ierase;            /* honor erase character?            */
  588.     char    ierasec;        /* erase character (backspace)       */
  589.     Bool    ikill;            /* honor line kill character?        */
  590.     char    ikillc;            /* line kill character               */
  591.     int    icursor;        /* current cursor position           */
  592.     Bool    oflow;            /* honor ostop/ostart?               */
  593.     Bool    oheld;            /* output currently being held?      */
  594.     char    ostop;            /* character that stops output       */
  595.     char    ostart;            /* character that restarts output    */
  596.     Bool    ocrlf;            /* echo CR/LF for LF ?               */
  597.     char    ifullc;            /* char to send when input full      */
  598.     struct csr    *ioaddr;    /* device address of this unit       */
  599. };
  600. extern struct tty    tty[];
  601.  
  602. # define    BACKSP        '\b'
  603. # define    BELL        '\07'
  604. # define    ATSIGN        '@'
  605. # define    BLANK        ' '
  606. # define    NEWLINE        '\n'
  607. # define    RETURN        '\r'
  608. # define    STOPCH        '\023'    /* control-S stops output            */
  609. # define    STRTCH        '\021'  /* control-Q restarts output         */
  610. # define    UPARROW        '^'
  611.  
  612. /* ttycontrol function codes */
  613.  
  614. # define    TCSETBRK    1    /* turn on BREAK in transmitter      */
  615. # define    TCRSTBRK    2    /* turn off BREAK in transmitter     */
  616. # define    TCNEXTC        3    /* look ahead 1 character            */
  617. # define    TCMODER        4    /* set input mode to raw             */
  618. # define    TCMODEC        5    /* set input mode to cooked          */
  619. # define    TCMODEK        6    /* set input mode to cbreak          */
  620. # define    TCICHARS    8    /* return number of input chars      */
  621. # define    TCECHO        9    /* turn on echo                      */
  622. # define    TCNOECHO    10    /* turn off echo                     */
  623. # define    TFULLC        BELL    /* char to echo when buffer is full  */
  624. /* xebec.h  p. 282 */
  625.  
  626. /* Xebec S1410 5.25 inch Winchester Disk Controller */
  627.  
  628. struct    xbdcb  {            /* Xebec disk controller registers   */
  629.     char    xop;            /* command calss/opcode              */
  630.     char    xunit;            /* unit/high-order address bits      */
  631.     char    xmaddr;            /* middle-order address bits         */
  632.     char    xladdr;            /* low-order address bits            */
  633.     char    xcount;            /* block count                       */
  634.     char    xcntl;            /* control field                     */
  635.     char    xres1;            /* reserved field #1                 */
  636.     char    xres2;            /* reserved field #2                 */
  637. };
  638.  
  639. /* Xebec controller operation codes */
  640.  
  641. # define    XOTDR        0    /* test drive ready                  */
  642. # define    XORCAL        1    /* recalibrate                       */
  643. # define    XORSS        3    /* request sense status              */
  644. # define    XOFMTD        4    /* format drive                      */
  645. # define    XOCTF        5    /* check track format                */
  646. # define    XOFMTT        6    /* format track                      */
  647. # define    XOFMTBT        7    /* format bad track                  */
  648. # define    XOREAD        8    /* read                              */
  649. # define    XOWRITE        10    /* write                             */
  650. # define    XOSEEK        11    /* seek                              */
  651. # define    XOINIT        12    /* initialize drive character.       */
  652. # define    XOREBEL        13    /* read ECC burst error length       */
  653. # define    XORAMD        14    /* perform RAM diagnostic test       */
  654.  
  655. # define    XRETRY        0    /* retry control byte                */
  656.